﻿@inject IOptions<WebsiteOptions> Options

<p><b>B 站相关视频链接</b></p>

@if (string.IsNullOrEmpty(VideoUrl))
{
    <div class="mb-3">暂无</div>
}
else
{
    <a class="fa fa-video-camera mb-3" href="@VideoUrl" target="_blank"><span class="ml-2">[传送门]</span></a>
}

@code {
    [NotNull]
    private string? VideoUrl { get; set; }

    [Parameter]
    public string? Name { get; set; }

    /// <summary>
    ///
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();

        if (!string.IsNullOrEmpty(Name) && Options.Value.Videos.TryGetValue(Name, out var url))
        {
            VideoUrl = $"{Options.Value.VideoUrl}{url}";
        }
    }
}
